package weekend01;

import java.util.ArrayList;
import java.util.Collection;

public class ListDemo {
    public static void main(String[] args) {
        Collection<Point> p = new ArrayList<>();
        p.add(new Point(1,2));
        p.add(new Point(3,4));
        p.add(new Point(5,6));
        p.add(new Point(7,8));
        p.add(new Point(9,0));
        p.add(new Point(1,2));
        System.out.println(p);

        Point p1 = new Point(1,2);
        System.out.println("集合是否包含点p1:"+p.contains(p1));

        p.remove(p1);
        System.out.println(p);

        System.out.println("集合是否为空集:"+p.isEmpty());

        p.clear();
        System.out.println("集合是否为空集:"+p.isEmpty());

        Collection<Integer> i = new ArrayList<>();
        i.add(1);
        i.add(2);
        i.add(3);
        i.add(4);
        i.add(5);
        System.out.println("listi:"+i);

        Collection<Integer> i1 = new ArrayList<>();
        i1.add(3);
        i1.add(4);
        i1.add(5);
        i1.add(6);
        i1.add(7);
        System.out.println("listi1:"+i1);

        i.addAll(i1);
        System.out.println("listi:"+i);
        System.out.println("listi1"+i1);

        System.out.println("i是否包含i1"+i.containsAll(i1));

        i.retainAll(i1);
        System.out.println("listi:"+i);
        System.out.println("listi1"+i1);

        i.removeAll(i1);
        System.out.println("listi:"+i);
        System.out.println("listi1"+i1);


    }
}
